import Flutter
import UIKit

@main
@objc class AppDelegate: FlutterAppDelegate {

    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {

       // GeneratedPluginRegistrant.register(withRegistry: self)
        GeneratedPluginRegistrant.register(with: self)

        setupChannelsManager()

        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }

    private func setupChannelsManager() {

        guard let controller = self.window?.rootViewController as? FlutterViewController else {
            print("❌ 无法获取FlutterViewController")
            return
        }

        // 使用Channel管理器设置所有Channel
        ChannelManager.shared.setupChannels(messenger: controller.binaryMessenger)

    }
}
